<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>采购(原材料/成品)入库信息管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/purchaseware";
		var basic_WUrl="logic/purchaseware";
		var basic_Title="添加";
		var show_Width=880;
		var show_Hight=500;
		function createSearch(){
			init(2,8,'100,100,100,100,100,100,100,100','10%');
			//第一行的数据
			addCommon(0,0,"lable","采购单号：");
			addCommon(0,1,"txtlike","zd002PcsCode");
			addCommon(0,2,"lable","入库单号：");
			addCommon(0,3,"txtlike","zd003Code");
			addCommon(0,4,"lable","仓库");
			addCommon(0,5,"selectEnum","zd007WhName","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd003Name}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,6,"lable","单据状态：");
			addCommon(0,7,"selectEnum","zd004Status","<option></option><option value='PCSW_SAVE'>草稿</option>"
						+"<option value='PCSW_SUBMIT'>已提交</option><option value='PCSW_AUDIT'>二级审核</option>"
						+"<option value='PCSW_APPROVE'>审核完成</option><option value='PCSW_BACK'>驳回</option>");
			addCommon(1,0,"lable","PI编号：");
			addCommon(1,1,"txtlike","zd016PiCode");
			addCommon(1,2,"lable","送货单号：");
			addCommon(1,3,"txtlike","zd017MaterialInCode");
			addCommon(1,4,"lable","入库起始时间");
			addCommon(1,5,"datestart","zd013Date");
			addCommon(1,6,"lable","入库结束时间");
			addCommon(1,7,"dateend","zd013Date");
			
		}
		
		function searchAP(){
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			var bol = false;
			if (rows==null){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}else{
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName !='${user.name}'){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('只能对本人建的单据进行删除操作!');
					return;
				}else{
					bol = false;
					for(var i=0;i<rows.length;i++){
					 	if (rows[i].zd004Status == 'PCSW_SAVE' || rows[i].zd004Status =='PCSW_BACK'){
					 		bol = true;
						}
					}
					if(bol){
						del();
						bol = false;
					}else{
						$.dialog.alert('草稿或退回状态的单据才能进行删除!');
						return;
					}
				}
			}
			
		}
		$(function(){
			var grid = $("#table1").ligerGrid({
		        columns: [{ display: '入库单号', name: 'zd003Code', width: 120 },
		                  { display: '采购编号', name: 'zd002PcsCode', width: 120 },
		                  { display: '仓库名称', name: 'zd007WhName', width: 80},
		                  { display: '单据状态', name: 'zd004Status', width: 80, render: function (item){
		                	  if(item.zd004Status=='PCSW_SAVE'){
		                		  return '草稿';
		                	  }else if(item.zd004Status=='PCSW_SUBMIT'){
		                		  return '已提交';
		                	  }else if(item.zd004Status=='PCSW_AUDIT'){
		                		  return '二级审核';
		                	  }else if(item.zd004Status=='PCSW_APPROVE'){
		                		  return '审核完成';
		                	  }else if(item.zd004Status=='PCSW_BACK'){
		                		  return '已退回';
		                	  }else{
		                		  return '已完结';
		                	  }
		                  }},
		                  { display: '付款状态', name: 'zd004PayStatus', width: 1,hide:true, render: function (item){
		                	  if(item.zd004PayStatus=='RENO'){
		                		  return '未付款';
		                	  }
		                	  if(item.zd004PayStatus=='SECT'){
		                		  return '部分付款';
		                	  }
		                	  if(item.zd004PayStatus=='COMP'){
		                		  return '完全付款';
		                	  }
		                  }},
		                  { display: 'PI编号', name: 'zd016PiCode', width: 100}, 
		                  { display: '客户名称', name: 'zd019AccountName', width: 200},
		                  { display: '送货单号', name: 'zd017MaterialInCode', width: 100},
		                  { display: '供应商', name: 'zd008SupeName', width: 100},
		                  { display: '创建人', name: 'bizCreatorName', width: 80},
		                  { display: '入库日期', name: 'zd013Date', width: 80,
		                	  render: function (item){
		                		  var zd013Date=new Date(item.zd013Date);
		                		  return formatDate(zd013Date,"yyyy-MM-dd");
		                	  }},
		                  { display: '备注', name: 'zd014Remark', width: 150 }
		                      ],  usePager: true,pageSize:15,pageSizeOptions :[15,30,45,60],enabledSort:false,
		                      url : basic_Url+"/list.do",
		                      width: "100%", height:"98%", checkbox: false,rownumbers:true,      
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edit(data);
		                       }
		                  });
			$("#pageloading").hide();
		});
		function excelEXport(){
			var filtersStr = generateCondition();
		   	var path = "${ctx}/excel/purchasewarenExcel.do?filters="+filtersStr+"&_search=true";
			window.open(path,"_blank");
		}
	</script>
	
  </head>
 <body style="padding:10px" onLoad="createSearch()">  
       <div id="layout1">
          <div class="panelBar">
	            <ul class="toolBar">
		           <li><a class="add" onclick="add()"><span>新增</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
			                 <li><a class="button" onclick="excelEXport()"><span>导出</span></a></li>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
   </div>
    </body>
</html>